//
//  NoiseFlowLayout.swift
//  DSP
//
//  Created by tucici on 2024/8/1.
//

import UIKit

class NoiseFlowLayout: UICollectionViewFlowLayout {
    override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
        let attributes = super.layoutAttributesForElements(in:rect)! as [UICollectionViewLayoutAttributes]
        let w = (self.collectionView?.frame.width ?? 0) - self.sectionInset.left - self.sectionInset.right
        for i in 0..<attributes.count{
            let attri = attributes[i]
            if i == attributes.count - 1{
                attri.frame = CGRect(x: (w - attri.frame.width) / 2.0 ,
                                     y:attri.frame.origin.y,
                                     width: attri.frame.width,
                                     height: attri.frame.height)
            }
        }
        return attributes
    }
}
